home *** CD-ROM | disk | FTP | other *** search
- /* GETPSP.C --- p. 612 */
- #include <stdio.h>
- #include <dos.h>
- main()
- {
- unsigned int mypsp, last_seg;
- long mem_allocated;
- /* If DOS version is at least 3.0, call getpsp */
- if(_osmajor == 3)
- mypsp = getpsp();
- /* else use global variable _psp to access PSP */
- else
- mypsp = _psp;
- /* Display some infomation from PSP */
- printf("PSP starts at %X:0000\n", mypsp);
- /* Address of last allocated memory is at offset 2 */
- last_seg = *((unsigned far *)(MK_FP(mypsp, 2)));
- printf("End of allocated memory at %X:000\n", last_seg);
- mem_allocated = 16*(long)(last_seg - mypsp);
- printf("%ld bytes of memory allocated to this "
- "program\n", mem_allocated);
- }